<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 2. Console</a><br />
<a href="console_init.html">&lt; 2.1 Initializing the console</a>
</td><td width="60%">
<p align="center">
=====================================<br />
2.1.8 Showing credits for libtcod<br />
=====================================<br />
</p></td><td width="20%">
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
You can print a "Powered by libtcod x.y.z" screen during your game startup simply by calling this function after initRoot :<br />
<p class="code"><pre>
C++ : static void TCODConsole::credits()
C   : void TCOD_console_credits()
Py  : console_credits()
</pre></p>
The credits screen can be skipped by pressing any key.<br />
Example :<br />
<p class="code"><pre>
C++ : TCODConsole::initRoot(80,50,"The Chronicles Of Doryen v0.1",false); // initialize the root console
      TCODConsole::credits(); // print the credits page
      // your game here...
C   : TCOD_console_init_root(80,50,"The Chronicles Of Doryen v0.1",false);
      TCOD_console_credits();
Py  : libtcod.console_init_root(80,50,"The Chronicles Of Doryen v0.1",False)
      libtcod.console_credits()
</pre></p>
<br />
<hr />
You can also print the credits on one of your game screens (your main menu for example) by calling this function in your main loop :<br />
<p class="code"><pre>
C++ : static bool TCODConsole::renderCredits(int x, int y, bool alpha)
C   : bool TCOD_console_credits_render(int x, int y, bool alpha)
Py  : console_credits_render(x, y, alpha)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>x,y</td><td>Position of the credits text in your root console</td></tr>
<tr><td>alpha</td><td>If true, credits are transparently added on top of the existing screen.<br />For this to work, this function must be placed between your screen rendering code and the console flush.<br /></td></tr>
</table>
This function returns true when the credits screen is finished, indicating that you no longer need to call it.
<br />
Example :<br />
<p class="code"><pre>
C++ : TCODConsole::initRoot(80,50,"The Chronicles Of Doryen v0.1",false); // initialize the root console
      bool endCredits=false;
      while ( ! TCODConsole::isWindowClosed() ) { // your game loop
          // your game rendering here...
          // render transparent credits near the center of the screen
          if (! endCredits ) endCredits=TCODConsole::renderCredits(35,25,true);
          TCODConsole::flush();
      }
C   : TCOD_console_init_root(80,50,"The Chronicles Of Doryen v0.1",false);
      bool end_credits=false;
      while ( ! TCOD_console_is_window_closed() ) {
          // your game rendering here...
          // render transparent credits near the center of the screen
          if (! end_credits ) end_credits=TCOD_console_credits_render(35,25,true);
          TCOD_console_flush();
      }
Py  : libtcod.console_init_root(80,50,"The Chronicles Of Doryen v0.1",False)
      end_credits=False
      while not libtcod.console_is_window_closed() :
          // your game rendering here...
          // render transparent credits near the center of the screen
          if (not end_credits )  : end_credits=libtcod.console_credits_render(35,25,True)
          libtcod.console_flush()
</pre></p>

